package net.simflow.swf.analyzer.graph.stats.opt;

import net.simflow.swf.analyzer.graph.stats.data.GraphStats;
import net.simflow.swf.analyzer.network.data.Link;
import net.simflow.swf.analyzer.network.data.Node;
import edu.uci.ics.jung.graph.Graph;

public class GraphStatsAnalyzer {

	private static GraphStatsAnalyzer instance = new GraphStatsAnalyzer();

	private GraphStatsAnalyzer() {
	}

	public static GraphStatsAnalyzer getInstance() {
		return instance;
	}

	public GraphStats analyze(String name, Graph<Node, Link> graph) {
		GraphStats ginfo = new GraphStats();
		ginfo.setGraph(graph);
		ginfo.setGraphName(name);
		ginfo.setNodeArray(GraphNodeListAnalyzer.getInstance().analyze(
				graph.getVertices()));
		ginfo.setLinkArray(GraphLinkListAnalyzer.getInstance().analyze(
				graph.getEdges()));
		ginfo.setDegreeDistribution(GraphDegreeDistributionAnalyzer
				.getInstance().analyze(graph));

		return ginfo;
	}
}
